﻿
@{
    ViewData["Title"] = "ListFrom";
}

@section Scripts
    {
    <link href="~/css/page.css" rel="stylesheet" />
    <script src="~/echats/echarts.js"></script>
    <script>
        var selfLayer = null;
        layui.use(['layer', 'table', 'laydate'], function () {
            var layer = layui.layer, form = layui.form, //弹层
                table = layui.table; //表格
            layui.laydate.render({
                elem: '#varRecordTime',
                type: 'year'
            })


            //  console.log(location.href);


            console.log('@Html.Raw(ViewBag.fishName)');
            var parameter =
            {
                fishName: '@Html.Raw(ViewBag.fishName)', //"大黄鱼",
                dateYear: '@Html.Raw(ViewBag.dateYear)',
                province:'@Html.Raw(ViewBag.province)',
                city:  '@Html.Raw(ViewBag.city)',
            }
            var myChart = echarts.init(document.getElementById("main"));

            $.get("/FishSpeciesReport/FishSpeciesMonthReport", parameter, function (result) {
                if (result.Code == "200") {
                    myChart.hideLoading();
                    // myChart.setOption(result.result);
                    result.data = JSON.stringify(result.result);

                    var dataX = [];
                    var dataY = [];

                    var thead = "<tr>";
                    var tbody = "<tr>";
                    for (var j = 0; j < result.result.length; j++) {
                        dataX.push(result.result[j].month+"月");
                        dataY.push(result.result[j].averagePrice);

                        thead += "<td>" + result.result[j].month + "</td>";
                        tbody += "<td>" + result.result[j].averagePrice + "</td>";
                    }

                    thead += "</tr>";
                    tbody += "/<tr>";


                    console.log(dataX);
                    console.log(dataY);
                    option = {
                        title: {
                            text: '@Html.Raw(ViewBag.dateYear)'+'年'+ '@Html.Raw(ViewBag.fishName)'+'鱼种月份走势分析',
                            x: 'center',
                            y: 20,
                        },
                        //   color: ['#47F4F6', '#FF4DA4', '#A67EFF', '#FFCD57', '#63E3BB', '#D955FF', '#3D98E5', '#FF8CBF', '#1FCFFF', '#FF9149', '#6CFF9B', '#FFE59F', '#2BECFF', '#D17AFF', '#5489FF', '#7EA5FF', '#72FFE1', '#FF7F87', '#34B3FF', '#FF8F7F'],
                        legend: {
                            textStyle: {
                                fontSize: 16
                            },
                            //x: 'center',
                            //y: -10,
                            //  data: legenddata
                        },
                        tooltip: {
                            trigger: 'axis',
                            textStyle: {//图例文字的样式
                                fontSize: 16
                            }
                        },
                        toolbox: {
                            x: '85%',
                            y: 20,
                            feature: {
                                magicType: {
                                    show: true,
                                    type: ['line', 'bar'],
                                    title: { line: '折线图切换', bar: '柱形图切换' },
                                    iconStyle: {
                                        emphasis: {
                                            textPosition: 'top'
                                        }
                                    }
                                },
                                saveAsImage: {
                                    show: true, title: '下载', iconStyle: {
                                        emphasis: {
                                            textPosition: 'top'
                                        }
                                    }
                                }
                            },
                            textStyle: {//图例文字的样式
                            }
                        },
                        xAxis: {
                            name:'月份', //'鱼种',
                            axisLabel: {
                                rotate: 10,
                                interval: 0

                            },
                            textStyle: {//图例文字的样式
                                fontSize: 16
                            },
                            data: dataX
                        },
                        yAxis: {
                            type: 'value',
                            name: '',
                            margin: 10,
                            textStyle: {
                            },
                            axisLabel: {
                                interval: 'auto',
                                rotate: -15,
                                margin: 18,
                                formatter: '{value}/元'
                            },
                            axisLine: {    // 轴线
                                show: true,
                                lineStyle: {
                                    type: 'dashed',
                                    width: 1
                                }
                            }
                        },
                        series: [
                            {
                                data: dataY,
                                type: 'bar'
                            }
                        ]
                    };
                    myChart.clear();
                    myChart.setOption(option);
                    $("#thdata").html(thead);
                    $("#tbdata").html(tbody);
                } else {
                    alert(result.msg);
                }

            });


        });


    </script>
}
<blockquote class="layui-elem-quote layui-text layui-form">
    <div class="layui-form-label">
        <button class="layui-btn" id="search" style="width: 60px; height: 28px; line-height: 28px; display: inline" data-type="reload">返回</button>
    </div>
</blockquote>
<br />
<div id="main" style="height: 600px; width: 100%;"></div>
<script src="~/js/jquery-1.11.1.min.js"></script>
<script>
    $(function () {
        $("#search").click(function () {
            window.location.href = "/FishSpeciesReport/List";
        })
    })
</script>

